package com.aaa.service.impl;


import com.aaa.entity.Role_fun;
import com.aaa.mapper.Role_funMapper;
import com.aaa.service.Role_funService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

@Service("role_funService")
public class Role_funServiceImpl implements Role_funService {

    //加载Mapper层接口
    @Resource
    Role_funMapper role_funMapper;

    /**
     * 批量插入
     * @param rid 角色id
     * @param fid 菜单id
     * @return
     */
    @Override
    public Integer add(Integer rid ,Integer[] fid){
        //遍历数组 然后使其循环调用mapper层方法 实现批量插入数据
        Integer result=null;
      //  Object[] array = Arrays.stream(fid).toArray();
        for (int i = 0; i < fid.length; i++) {
                result= role_funMapper.add(rid,fid[i]);
        }
        return result;
    }

    /**
     * 根据角色id删除该角色所拥有的权限数据
     * @param rid
     * @return
     */
    @Override
    public Integer del(Integer rid) {
        return role_funMapper.del(rid);
    }
}
